<?php

namespace App\Http\Controllers\Api\V3;

use App\Libs\BaiDuYun\Live;
use BaiduBce\Services\Bos\BosClient;
use BaiduBce\Services\Lss\LssClient;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Response;

class LiveController extends Controller
{
    public $lssClient;

    public function __construct()
    {

    }

    public function index()
    {
        $file = public_path() . '/../app/Libs/BaiDuYun/BaiduLive/BaiduBce.phar';
        if (file_exists($file)) {
            include $file;
            include public_path() . '/../app/Libs/BaiDuYun/BaiduLive/LiveConf.php';

            global $LSS_TEST_CONFIG;
            $LSS_TEST_CONFIG = [
                'credentials' => [
                    'accessKeyId' => '8aab1f45618f4eefb98e26a469310d03',
                    'secretAccessKey' => '747ad75383974f5f92a41d4b2906a349',
//                    'sessionToken' => 'your session token'
                ],
//                'endpoint' => 'http://lss.bj.baidubce.com',
//                'stsEndpoint' => 'sts host',
            ];
//            dd($LSS_TEST_CONFIG);
            $client = new LssClient($LSS_TEST_CONFIG);
//            $client = new LssClient($LSS_TEST_CONFIG);
            $this->lssClient = $client;
            $domain = '<rtmp://push.wx.laohoulundao.com>';
            $app = '<lhdd>';
            $stream = '<lhdd/fdajklfajkldajflkdaj324>';

            $response = $this->lssClient->getStream($domain, $app, $stream);
            foreach ($response->streams as $stream) {
                dump(json_encode($stream));
            }
            return 'ok1';
        } else {
            return 'no';
        }
    }

//    public function index(Request $request)
//    {
//        $domain = 'test.wx.laohoulundao.com';
//        $response = $this->lssClient->listStreams($domain);
//        foreach ($response->streams as $stream) {
//            dump(json_encode($stream));
//        }
//    }
}
